package com.ly.lw.styledo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.ly.lw.styledo.R;
import com.ly.lw.styledo.bean.Normal;
import com.ly.lw.styledo.bean.PlanList;
import com.nostra13.universalimageloader.core.DisplayImageOptions;

import java.util.List;

/**
 * Created by sks on 15-7-6.
 */
public class MainDetailAdapter extends AppBaseAdapter<PlanList>{

    private BitmapUtils bitmapUtils;
    private DisplayImageOptions options;

    public MainDetailAdapter(List<PlanList> list, Context context, BitmapUtils bitmapUtils) {
        super(list, context);
        this.bitmapUtils = bitmapUtils;
        DisplayImageOptions.Builder builder = new DisplayImageOptions.Builder();
        builder.showImageOnLoading(R.mipmap.ic_default_item);
        builder.showImageOnFail(R.mipmap.ic_default_item);
        options = new DisplayImageOptions.Builder()
                .cacheInMemory(true)//设置下载的图片是否缓存在内存中
                .cacheOnDisc(true)//设置下载的图片是否缓存在SD卡中
                .build();
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_main_detail_layout, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);

        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        String imgUrl = list.get(position).getBanner_img().replace("${width}x${height}", "800x800");
        bitmapUtils.display(holder.imageView,imgUrl);
        String s = list.get(position).getPlan_desc();
        //ImageLoader.getInstance().displayImage(list.get(position).getImgUrl(), holder.imageView, options);
        //bitmapUtils.display(holder.logoImg, list.get(position).getBrandLogo());
        //ImageLoader.getInstance().displayImage(list.get(position).getBrandLogo(), holder.logoImg, options);
       // holder.textPrice.setText(list.get(position).getLikeCnt());
       // holder.likeView.setText(list.get(position).getLikeCnt());

        return convertView;
    }

    private static class ViewHolder {
        ImageView imageView;
        TextView textPrice;
        TextView likeView;

        public ViewHolder(View itemView) {
            imageView = (ImageView) itemView.findViewById(R.id.item_main_img);

        }
    }


}
